<?php
if ( defined('ABSPATH') )
	include_once ABSPATH . 'config.php';
else
    include_once 'config.php';

include_once ABSPATH."base/curl.php";
include_once ABSPATH."base/people.php";
include_once ABSPATH."base/channels.php";

if(isset($_COOKIE["ombid"]))
{
	$id = $_COOKIE["ombid"];
}
else
{
	header("Location: index.php");
}

if(isset($_POST["btnAdd"]))
{
	$channel = new Channel();
	$channel->Create($id,$_POST["txtName"]);
}

if(isset($_GET["id"]))
{
	$channel = new Channel($_GET["id"]);
	$channel->Delete();
}



include_once THEME_PATH."header.php";

?>
<div id="page">
<?php include_once "header.php"; ?>
<div id="content" class="widecolumn">
<input type="hidden" id="id">
<a href="index.php">Home</a>
<p>&nbsp;</p>
<div>
<form method="post">
<div id="channelInstructions">
<p>Type in the name of a group below.  Click on the <strong>Add</strong> button to add the group.</p>
<p>Click on the <strong>X</strong> next to the group name to delete a group.
</div>
<p>&nbsp;</p>
<table>
<tr><td><strong>Name</strong></td><td><input name="txtName" type="text" /></td></tr>
<tr><td>&nbsp;</td><td></td></tr>
<tr><td></td><td><input name="btnAdd" type="submit" value="Add"></td></tr>
<tr><td>&nbsp;</td><td></td></tr>
</table>
</div>
<?php

$channels = new Channels();
$rs = $channels->Get($id);

if($rs)
{
	foreach($rs as $row)
	{
	    echo '<p>'.$row["name"].'&nbsp;&nbsp;<a href="channels.php?id='.$row["id"].'" title="Delete" onclick="return confirm(\'Delete this group?\');">X</a></p>';	
	}
}



?>


</form>
</div>
<?php include_once THEME_PATH."footer.php";?>
